package pacman;
/*
 * Position.java
 *
 * Created on 14. juin 2007, 14:28
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 * An int position x,y in the game
 */
public class Position{
    
    private int x;
    private int y;
    
    /**
     * Creates a new instance of Position.
     * @param   x   x axis (horizontal) value of position
     * @param   y   y axis (vertical) value of positon
     */
    public Position(int x,int y) {
        this.x=x;
        this.y=y;
    }
    
    /**
     * Returns the x axis (horizontal) value of position.
     * @return  the x axis (horizontal) value of position
     */
    public int getX(){
        return x;
    }
    
    /**
     * Sets the x axis (horizontal) value of position.
     * @param   newX    the new value to be set for x axis (horizontal) of position
     */
    public void setX(int newX){
        x=newX;
    }
    
    /**
     * Returns the y axis (vertical) value of position.
     * @return  the y axis (vertical) value of position
     */
    public int getY(){
        return y;
    }
    
    /**
     * Sets the y axis (vertical) value of position.
     * @param   newY    the new value to be set for y axis (vertical) of position
     */
    public void setY(int newY){
        x=newY;
    }
    
    /**
     * Adds a value to the x axis (horizontal) value of position.
     * @param   dX  the value to be added to x axix (horizontal) value of position
     */
    public void incX(int dX) {
        x += dX;
    }
    
    /**
     * Adds a value to the y axis (vertical) value of position.
     * @param   dY  the value to be added to y axix (vertical) value of position
     */
    public void incY(int dY) {
        y += dY;
    }
    
    /**
     * Says if this position equals another position.
     * @param   pos the position to be compared to.
     * @return      true if positions are the same, otherwise false
     */
    public boolean equals(Position pos){
        if(pos.getX()==this.getX() && pos.getY()==this.getY()){
            return true;
        }
        return false;
    }
    
    /**
     * Creates a clone of this position.
     * @return      a clone of this position
     */
    @Override
    public Position clone(){
        return new Position(this.getX(),this.getY());
    }
}
